#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>

typedef struct BTNode
{
    char a;
    struct BTNode* left;
    struct BTNode* right;
}BTNode;

BTNode* BuyBTNode(char x)
{
    BTNode* tmp = (BTNode*)malloc(sizeof(BTNode));
    if (tmp == NULL)
    {
        perror("malloc error");
        return NULL;
    }
    tmp->a = x;
    tmp->left = NULL;
    tmp->right = NULL;
    return tmp;
}

BTNode* CreatTree(char* a, int* i)
{
    if (a[*i] != '#')
    {
        BTNode* newnode = BuyBTNode(a[*i]);
        (*i)++;
        newnode->left = CreatTree(a, i);
        newnode->right = CreatTree(a, i);
        return newnode;
    }  
    (*i)++;
    return NULL;
}

void InOrder(BTNode* root)
{
    if (root == NULL)
        return;

    InOrder(root->left);
    printf("%c ", root->a);
    InOrder(root->right);
}

int main()
{
    char a[100];
    scanf("%s", a);

    int i = 0;
    BTNode* root = CreatTree(a, &i);
    InOrder(root);
    printf("\n");


    return 0;
}